package com.ga.controller;

import java.io.File;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.ga.model.Album;
import com.ga.model.Reply;
import com.ga.model.User;
import com.ga.model.Video;
import com.ga.util.Common;
import com.jfinal.aop.ClearInterceptor;
import com.jfinal.aop.ClearLayer;
import com.jfinal.core.ActionKey;
import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Db;
import com.oreilly.servlet.MultipartRequest;

public class IndexController extends Controller {
	@ClearInterceptor(ClearLayer.ALL)
	public void index() {
		render("index.html");
	}
	
	@ActionKey("/test")
	public void test() {
		Map map = new HashMap();
		try {
			HttpServletRequest request=this.getRequest();
			System.out.println(request.getParameter("aa"));
			System.out.println(request.getAttribute("aa"));
			System.out.println(request.getParameterMap());
			Long l1=System.currentTimeMillis();
			System.out.println(Common.contextClassPath);

			String root=this.getSession().getServletContext().getRealPath("/");
			this.getRequest().setCharacterEncoding("utf-8");
			MultipartRequest mr=new MultipartRequest(this.getRequest(), root,500*1024*1024);
			File file=mr.getFile("testfile");
			
			Long l2=System.currentTimeMillis();
			map.put("t", l2-l1);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		renderJson(map);
		
	}
}
